<template>
	<view class="list_wrap">
		<view class="item" v-for="(item, index) in notices" :key='index' @click="handleToDetail(item.id)">
			<text>{{item.title}}</text>
			<view>{{item.createTime}}</view>
		</view>
	</view>
</template>

<script>
	import {
		requestGet
	} from '@/utils/request.js'
	export default {
		data() {
			return {
				notices: [{
					title: '忽闻水上琵琶声，主人忘归客不发。寻声暗问弹者谁？琵琶声停欲语迟。',
					date: '2075 - 09 - 25 11:01'
				}, {
					title: '李白，字太白，号青莲居士，唐朝浪漫主义诗人，被后人誉为“诗仙”。祖籍陇西成纪，出生于西域碎叶城，4岁再随父迁至剑南道绵州。李白，字太白，号青莲居士，唐朝浪漫主义诗人，被后人誉为“诗仙”。祖籍陇西成纪，出生于西域碎叶城，4岁再随父迁至剑南道绵州。',
					date: '2064 - 12 - 03 12:28'
				}],
				hasMore: true,
				pageNum: 1
			}
		},
		mounted() {
			this.getNotices()
		},
		onReachBottom() {
			if (this.hasMore) {
				this.getNotices()
			}
		},
		methods: {
			handleToDetail(id) {
				uni.navigateTo({
					url: `/page_index/notice/detail?id=${id}`
				})
			},
			getNotices() {
				requestGet(`/home/content/list?channelId=2&pageNum=${this.pageNum}&pageSize=10`, null, '/baseplatform').then(res => {
					if (res.code === 200) {
						console.log('公告列表', res)
						this.notices = res.rows
						this.hasMore = res.total > this.pageNum * pageSize
						this.pageNum += 1
					}
				}).catch((err) => console.log('错误了', err))
			}
		}
	}
</script>

<style lang="scss" scoped>
	.list_wrap {
		width: 100%;
		min-height: 100vh;
		background: #F5F7F6;
		box-sizing: border-box;
		padding: 16rpx 32rpx 0;

		.item {
			box-sizing: border-box;
			padding: 24rpx;
			background: #fff;
			border-radius: 24rpx 24rpx 24rpx 24rpx;
			margin-bottom: 16rpx;

			text {
				width: 100%;
				font-size: 28rpx;
				font-weight: 400;
				color: rgba(0, 0, 0, 0.8);
				line-height: 40rpx;
				display: -webkit-box;
				-webkit-line-clamp: 3;
				-webkit-box-orient: vertical;
				overflow: hidden;
				text-overflow: ellipsis;
			}

			view {
				font-size: 24rpx;
				font-weight: 400;
				color: rgba(0, 0, 0, 0.5);
				line-height: 34rpx;
				margin-top: 24rpx;
			}
		}
	}
</style>